Add support for single line statement (if .... then ... [else ...])#12
Conversation
verhas
left a comment
There was a problem hiding this comment.
Please see my comments and amend the code appropriately. They are mainly small things but there is one coding that is significant. Please refactor that method.
| @@ -0,0 +1,8 @@ | |||
| ' | |||
There was a problem hiding this comment.
we need much more complex test cases, like
if true then if true then print "a" else print "b" else print "c"
There was a problem hiding this comment.
The single-line 'IF' statement is very dangerous because it does not address properly the dangling ELSE problem. There can be many different cases. One command between the 'THEN' and 'ELSE', many commands, empty commands.
IF x THEN a=1 :ELSE: IF y THEN: a=2 ELSE: a=3
This is the main reason that one line IF was not implemented in ScriptBasic. There was no aim to be compatible with RealBASIC or any other basic.
I accept compatibility with any BASIC as that increases usability and after all the ultimate goal is that ppl use the program. Still it feels a bit itchy.
There was a problem hiding this comment.
I tested more complex single-line 'IF' statements and fixed one more issue. There are two tests (TestIf3.bas and TestIf4.bas) to verify these cases. I tested same IF statements in Visual Basic with same results.
|
I will prepare a few smaller pull requests as preparation for this one. |
|
Please make the modifications and resolve the conflict merging the origin master to your branch. |
…on as a statement separator
d4c7a8a to
df3351c
Compare
df3351c to
12abe81
Compare
12abe81 to
103d740
Compare
Add support for single line statement: if .... then ... [else ...]
See https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/if-then-else-statement